#!/usr/bin/python
# -*- coding: UTF-8 -*-
import pymysql
# 打开数据库连接
db = pymysql.connect(host="172.31.11.63", port=3306, user="djangotest", password="P52koMfruQGpWG226XqxLf3J", db="djangotest")

# 使用cursor()方法获取操作游标
cursor = db.cursor()

# sql 更新语句
sql = "update EMPLOYEE set AGE = AGE + 1 where SEX = '%c'" %('M')

try:
    # 执行sql语句
    cursor.execute(sql)
    # 提交到数据库执行
    db.commit()
except:
    # 发出错误时回滚
    db.rollback()
# 关闭数据库连接
db.close()